package com.itboye.shop.util.loadutil;

import android.annotation.SuppressLint;
import android.app.Activity;

/**
 * Created by admin on 2017/1/13.
 */

public class LoadingUtil {

   static LoadingDialog progressDialog =null;
    /**
     * 显示进度对话框,带有消息 flag 是否可以取消
     */
    @SuppressLint("NewApi")
    public static void showProgressDialog(Activity activity,String message, boolean flag) {
        progressDialog = new LoadingDialog();
        if (progressDialog == null)
            return;
        setProgressDialogMessage(message);

        progressDialog.show(activity.getFragmentManager(), message);
        progressDialog.setCancelable(flag);

    }
    /**
     * 关闭进度对话框
     */
    @SuppressLint("NewApi")
    public static void closeProgressDialog() {
        if (progressDialog != null) {
//			if (progressDialog.getDialog().isShowing()) {
            progressDialog.dismiss();
//			}
        }
    }

    /**
     * 设置进度对话框消息
     *
     * @param message
     */
    public static void setProgressDialogMessage(String message) {
        progressDialog.setMsg(message);
    }
}
